package com.gupaoedu.vip.pattern.observer.subject;

import java.lang.reflect.Method;

/**
 * Created by Administrator on 2018/7/6.
 */
public class ObserverTest {

    public static void main(String[] args) {
        try{
            //观察者
            Observer observer = new Observer();
            Method method = Observer.class.getMethod("advice",new Class<?>[]{Event.class});

            Subject subject = new Subject();
            subject.addLisenter(SubjectEventType.ON_ADD,observer,method);
            subject.addLisenter(SubjectEventType.ON_REMOVE,observer,method);

            subject.add();
            subject.remove();

        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
